package com.gs.netty.server.config;


import com.gs.netty.server.WebSocketServer;

import com.gs.netty.server.auth.WebSocketAuthHandler;
import com.gs.netty.support.dispatch.WebSocketDispatch;
import com.gs.netty.server.NettyServerConfig;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class WebSocketServerAutoConfiguration {

    @Bean
    public NettyServerConfig nettyServerConfig() {
        return new NettyServerConfig();
    }

    @Bean
    public WebSocketServer webSocketServer(@Autowired WebSocketDispatch webSocketDispatch) throws Exception {
        NettyServerConfig nettyServerConfig = nettyServerConfig();
        WebSocketAuthHandler webSocketAuthHandler = new WebSocketAuthHandler(nettyServerConfig);
        return new WebSocketServer(nettyServerConfig,webSocketDispatch,webSocketAuthHandler);
    }


}



